package com.pc.controller;

import com.pc.pojo.UserAccount;
import com.pc.result.Result;
import com.pc.service.LoginService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
public class Login {

    @Autowired
    private LoginService loginService;


    @PreAuthorize("hasAnyAuthority('user:delete')")
    @DeleteMapping ("/delete/{userId}")
    public Result<String> delete(@PathVariable long userId){
        loginService.delete(userId);
        return Result.success("删除成功");
    }

    @PostMapping("/register")
    public Result<String> register(@RequestBody UserAccount userAccount){

        loginService.register(userAccount);
        return Result.success("注册成功");
    }
}
